package com.wz.compilerManual.add.symbol;

import com.wz.compilerManual.Symbol;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class S_number extends Symbol {

    @Override
    public boolean match(String str) {
        return isNumericzidai(str);
    }

    public static boolean isNumericzidai(String str) {
        Pattern pattern = Pattern.compile("-?[0-9]+\\.?[0-9]*");
        Matcher isNum = pattern.matcher(str);
        if (!isNum.matches()) {
            return false;
        }
        return true;
    }

    @Override
    public boolean isTerminal() {
        return true;
    }

    @Override
    public String toString() {
        return "n";
    }
}
